var Iter = {
  [Symbol.iterator]: function () {
    var i = 0
    return {
      next: function () {
        return i++
      }
    }
  }
}
const i = Iter[Symbol.iterator]()
console.log(i.next())
console.log(i.next())


// Iterator的遍历
function myIter (array) {
  this.array = array
}
myIter.prototype[Symbol.iterator] = function () {
  let index = 0
  var nextFunc = () => {
    if (index < this.array.length) {
      return {
        value: this.array[index++],
        done: false
      }
    } else {
      return {value: undefined, done: true}
    }
  }
  return {next: nextFunc}
}
var myi = new myIter(['a', 'b', 'c'])
for (let i of myi) {
  console.log(i)
}

